package example.op.base;

import com.sun.jna.platform.win32.COM.util.ObjectFactory;
import op.OpInit;
import op.OpSoft;

import java.util.logging.Logger;

/**
 * 设置和获取OP插件路径
 * @author wyl
 * @version 1.0
 * @date 2025/8/9 11:27
 */
public class SetAndGetPath {
    private static final Logger logger = Logger.getLogger(SetAndGetPath.class.getName());

    public static void main(String[] args) {
        // 初始化OP插件
        OpInit.init("D:\\op\\tools.dll", "D:\\op\\op_x64.dll");

        ObjectFactory objectFactory = new ObjectFactory();
        OpSoft opSoft = objectFactory.createObject(OpSoft.class);

        // 设置全局路径 **一定要有这个文件夹
        String newPath = "D:\\op";
        int setResult = opSoft.setPath(newPath);
        logger.info("设置路径结果: " + (setResult == 1 ? "成功" : "失败"));

        // 获取当前路径
        String currentPath = opSoft.getPath();
        logger.info("当前全局路径: " + currentPath);

        // 获取插件基础路径
        String basePath = opSoft.getBasePath();
        logger.info("插件基础路径: " + basePath);
    }
}